package com.asa.rippleanimationview

import android.content.Context
import android.graphics.Canvas
import android.util.AttributeSet
import android.util.Log
import android.view.View
import kotlin.math.min

/**
 * create By：anderson
 * on 2022/5/8
 * desc:
 */
class RippleCircleView(private val rippleAnimationView: RippleAnimationView) : View(rippleAnimationView.context) {


    private var centerX: Float = 0f
    private var centerY: Float = 0f
    private var radius: Float = 0f

    init {
        visibility = INVISIBLE
    }


    override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
        super.onSizeChanged(w, h, oldw, oldh)
        centerX = w / 2f
        centerY = h / 2f
        radius = min(w / 2f, h / 2f)
    }


    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        Log.e("日志", "onDraw: radius:${radius}")

        canvas?.drawCircle(centerX,centerY,radius,rippleAnimationView.paint)
    }

}